package dao.impl;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class IntermediaryMethodInterceptor implements MethodInterceptor {
    /**
     * 为被代理的方法定义的代理业务规则
     * @param o
     * @param method
     * @param objects
     * @param methodProxy
     * @return
     * @throws Throwable
     */
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        before();
        //调用父类原始的方法
        Object invoke = methodProxy.invokeSuper(o, objects);
        after();
        return "看房记录：买家反馈"+invoke;
    }
    public void before(){
        System.out.println("看房");
    }
    public void after(){
        System.out.println("看完了");
    }
}
